<div class="wrap">
    <div class="container">
        <div class="row">
            <div id="secondary" class="col-md-2">
                <nav class="list-group mt30">
                    <a href="/user/settings" class="list-group-item">
                        个人资料
                    </a>
                    <a href="{:U('index/settings/face')}" class="list-group-item">
                        头像修改
                        <i style="line-height: 20px;font-size: 12px;color: #999;" class="pull-right fa fa-external-link-square">
                        </i>
                    </a>
                    <a href="{:U('index/settings/email')}" class="list-group-item">
                        Email 地址
                    </a>
                    <a href="{:U('index/settings/password')}" class="list-group-item active">
                        密码修改
                    </a>
                    <a href="/user/settings?tab=oauth" class="list-group-item">
                        第三方账号
                    </a>
                </nav>
                <nav class="list-group mt30">
                    <a href="/user/settings?tab=notify" class="list-group-item">
                        通知和私信
                    </a>
                    <a href="/user/settings?tab=card" class="list-group-item">
                        个性名片
                    </a>
                    <a href="/user/settings?tab=block" class="list-group-item">
                        屏蔽名单
                    </a>
                    <a href="/user/settings?tab=lab" class="list-group-item">
                        实验室功能
                    </a>
                </nav>
            </div>
            <!-- end #secondary -->
            <div id="main" class="settings col-md-10 form-horizontal">
                <form id="setting" action="{:U('index/settings/updatepwd')}" method="post">
                    <h2 class="h3 mt30 post-title">
                        密码修改
                    </h2>
                    <div class="form-group mt30">
                        <label for="oldpassword" class="required control-label col-sm-2">
                            当前密码
                        </label>
                        <div class="col-sm-8">
                            <input name="password" id="oldpassword" type="password" class="form-control"
                            required="">   
                            <span class="reform">请输入当前密码</span>                         
                        </div>
                        
                    </div>
                    <div class="form-group">
                        <label for="newpassword" class="required control-label col-sm-2">
                            新密码
                        </label>
                        <div class="col-sm-8">
                            <input name="newPassword" id="newpassword" type="password" class="form-control"
                            required="">
                            <span class="reform">请输入新密码</span>
                        </div>
                        
                    </div>
                    <div class="form-group">
                        <label for="confirmPassword" class="required control-label col-sm-2">
                            确认新密码
                        </label>
                        <div class="col-sm-8">
                            <input name="confirmPassword" id="confirmPassword" type="password" class="form-control"
                            required="">
                            <span class="reform">请确认密码</span>
                        </div>
                        
                    </div>
                    <div class="form-action row">
                        <div class="col-sm-10 col-sm-offset-2">
                            <button class="btn btn-xl btn-primary password-sub" disabled="">
                                提交
                            </button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>

<script type="text/javascript">    
    // $('#oldpassword').blur(function(event) {
    //     var value = $(this).val();
    //     if (value=='') {
    //         $('.reform').html('<span style="color:red">密码不能为空</span>');
    //         return false;
    //     }
    // $.ajax({
    //         url: '{:U('Index/settings/checkpassword')}',
    //         type: 'post',
    //         dataType: 'json',
    //         data: {passwordvalue:value},   
    //         success:function(data){
    //             if( data.error == 1 ){
    //                 $('.reform').html('<span style="color:red">'+data.msg+'</span>');
    //                 $('.btn-xl').attr('disabled','');
    //             }else{
    //                 $('.reform').html('<span style="color:green">'+data.msg+'</span>');
    //                 $('.btn-xl').removeAttr('disabled','');
    //             }
    //         },
    //         error:function(){
    //         }
    //     })
    // })

    
    $('#oldpassword,#newpassword,#confirmPassword').blur(function(event) {
        var currentvalue = $(this).val();
        var this1 = $(this);

        var currentname  = $(this).attr('id');
        $.ajax({
            url: '{:U("index/settings/checkthis")}',
            type: 'POST',
            dataType: "json",
            data: currentname + "=" + currentvalue,
            success:function(data){
                if( data.error == 1){
                    
                    this1.siblings('.reform').html('<span style="color:green">'+data.msg+'</span>');
                    $('.btn-xl').removeAttr('disabled','');
                }else{

                    this1.siblings('.reform').html('<span style="color:red">'+data.msg+'</span>');                    
                    $('.btn-xl').attr('disabled','');
                }
            },
            error:function(){
                
            }

        })               
    });



</script>

